chore(#10543): add PERSON contact type constant and replace magic strings#11235
Open
Saish31 wants to merge 3 commits into
Open
chore(#10543): add PERSON contact type constant and replace magic strings#11235Saish31 wants to merge 3 commits into
Saish31 wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a
PERSONconstant toCONTACT_TYPESin@medic/constants, and replaces hardcoded'person'magic strings withCONTACT_TYPES.PERSONacross the codebase where the string represents a contact/doc type check (not an id, and not inside a CouchDB view function).Changes
shared-libs/constants/src/index.js: addedPERSON: 'person'toCONTACT_TYPESshared-libs/contact-types-utils/src/index.jsshared-libs/transitions/src/transitions/registration.jsshared-libs/cht-datasource/src/local/person.tsshared-libs/contacts/src/people.jswebapp/web-components/cht-form/src/app.component.tswebapp/src/ts/services/contact-save.service.tsadmin/src/js/services/import-contacts.jsIntentionally not changed
ddocs/medic-db/medic-client/views/contacts_by_type/map.jsandcontacts_by_parent/map.js, andwebapp/src/js/bootstrapper/offline-ddocs/medic-offline-freetext/*.js: these are CouchDB map functions that get serialized via.toString()and executed by CouchDB in complete isolation — they cannotrequire()shared constants.'person'is used as an id value rather than a type check (e.g. test fixtures,contact: 'person').config/demo/**andconfig/default/**sample app configuration files, which aren't part of the@medic/*shared-lib ecosystem.Testing
Ran unit tests for every affected package locally, all passing:
shared-libs/contact-types-utils: 56 passing, 100% coverageshared-libs/transitions: 879 passingshared-libs/cht-datasource: 1055 passingshared-libs/contacts: 83 passing, 100% coveragewebapp(incl.cht-form): 2796 passingadmin: 431 passingAlso ran
eslinton all changed files with no errors.AI Disclosure
Used Claude to review code changes as this was my first open source contribution.
Fixes #10543